package com.mhy.netsafe.base;

import android.content.Intent;
import android.os.Bundle;

import androidx.annotation.Nullable;
import androidx.appcompat.app.AppCompatActivity;
import androidx.core.content.ContextCompat;

import com.mhy.netsafe.utils.MToast;
import com.mhy.netsafe.utils.ToastUtil;
import com.mhy.toast.ToastUtils;
import com.mhy.netsafe.MyApplication;
import com.mhy.netsafe.R;
import com.qmuiteam.qmui.util.QMUIStatusBarHelper;
import com.qmuiteam.qmui.widget.QMUITopBar;
import com.squareup.leakcanary.RefWatcher;



/**
 * author    : mahongyin
 * e-mail    : mhy.work@qq.com
 * date      : 2019/6/12B 15:05
 * introduce :
 */

public abstract class BaseActivity extends AppCompatActivity {

    protected MyApplication mineApplication;

    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
       // UETool.showUETMenu();
        mineApplication = (MyApplication) getApplication();

    }

    protected abstract void initData();

    protected abstract void initViews();

    protected void setTopBar(QMUITopBar topbar) {
        topbar.setBackgroundColor(ContextCompat.getColor(this, R.color.colorWhiteA));
        // 沉浸式状态栏
        QMUIStatusBarHelper.translucent(this);
        //设置状态栏黑色字体和图标，
        //支持4.4以上的MIUI和flyme  以及5.0以上的其他android
        QMUIStatusBarHelper.setStatusBarLightMode(this);
    }

    protected void showToast(String message) {
        ToastUtils.show(message);
    }

    protected void startActivity(Class<?> cls) {
        Intent intent = new Intent(this, cls);
        startActivity(intent);
    }

    protected void showLoading(){

    }

    protected void hideLoading(){

    }
    @Override
    protected void onDestroy() {
        super.onDestroy();
//        UETool.dismissUETMenu();
        ToastUtils.cancel();
        // 测试有无内存泄漏
        RefWatcher refWatcher = MyApplication.getRefWatcher(this);
        refWatcher.watch(this);
    }
    }
//打开悬浮窗
//UETool.showUETMenu();
//    or
//UETool.showUETMenu(int y);
//    关掉悬浮窗
//UETool.dismissUETMenu();